//
//  HelloWorldLayer.m
//  cocos2dFirstTest
//
//  Created by Daniel Alexander on 6/13/11.
//  Copyright __MyCompanyName__ 2011. All rights reserved.
//


// Import the interfaces
#import "MainMenuLayer.h"

// HelloWorldLayer implementation
@implementation MainMenuLayer

+(CCScene *) scene
{
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	MainMenuLayer *layer = [MainMenuLayer node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
    //CCDirector *director = [CCDirector sharedDirector];
    
	// return the scene
	return scene;
}

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super" return value
	if( (self=[super init])) {
        
        //CGFloat screenHeight = [[CCDirector sharedDirector] winSizeInPixels].height;
        CGFloat screenWidth = [[CCDirector sharedDirector] winSizeInPixels].width;
        
        [self addChild:MenuBackgroundLayer.scene];
        
        [CCMenuItemFont setFontName:@"font.ttf"];
        [CCMenuItemFont setFontSize:24];
        
        CCLabelTTF *title = [CCLabelTTF labelWithString:@"5-Nachos Awesomeness" fontName:@"font.ttf" fontSize:32];
        title.position =  ccp(screenWidth / 2, 290);
        title.color = ccc3(255, 255, 0);
        [self addChild: title];
        
        CCMenuItemFont *joinMenuItem = [CCMenuItemFont itemFromString:@"Join the Awesomeness!" target:self selector: @selector(joinGame:)];
        
        
        CCMenu *menu = [CCMenu menuWithItems:joinMenuItem,nil];
        menu.position = ccp(screenWidth / 2, 200);
        [menu alignItemsVerticallyWithPadding: 40.0f];
        [self addChild:menu z: 2];
        
	}
	return self;
}

- (void) joinGame:(id)sender{
    [[CCDirector sharedDirector] replaceScene: [CharacterCreateScreen scene]];
}

// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)
	
	// don't forget to call "super dealloc"
	[super dealloc];
}
@end
